package com.jshoperxms.components.upload.qiniu;

import com.qiniu.common.QiniuException;
import com.qiniu.http.Response;
import com.qiniu.storage.UploadManager;
import com.qiniu.util.Auth;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;


/**
 * 七牛上传文件
* @ClassName: QiNiuUploadsFile 
* @Description: TODO
* @author sdywcd@gmail.com
* @date 2015年3月20日 下午12:22:47 
*
 */
public class QiNiuUploadFiles {
	private Logger log = LoggerFactory.getLogger(QiNiuUploadFiles.class);

	public void uploads(String localFile, String key)throws IOException {
		Auth auth=Auth.create(QiNiuConfig.ACCESS_KEY, QiNiuConfig.SECRET_KEY);
		UploadManager uploadManager=new UploadManager();
		try{
			Response res=uploadManager.put(localFile, key, auth.uploadToken(QiNiuConfig.BUCKETNAME));
		}catch(QiniuException e){
			log.debug("qiniu throw a error"+e.response.toString());
		}
	}

	
}
